package com.atguigu.spzx.pay.service.Impl;

import com.atguigu.spzx.model.entity.pay.PaymentInfo;
import com.atguigu.spzx.pay.mapper.PaymentInfoMapper;
import com.atguigu.spzx.pay.service.PaymentInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author LT
 * @create 2024-04-01-18:34
 */
@Service
public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, PaymentInfo> implements PaymentInfoService {


    @Async
    @Override
    public void saveAsync(PaymentInfo paymentInfo) {
        this.save(paymentInfo);
    }

    @Override
    public PaymentInfo getByOrderNo(String outTradeNo) {
        PaymentInfo paymentInfo = this.getOne(Wrappers.lambdaQuery(PaymentInfo.class)
                .eq(PaymentInfo::getOrderNo, outTradeNo));
        return paymentInfo;
    }

    @Async
    @Override
    public void updatePaymentStatus(PaymentInfo paymentInfo) {
        this.updateById(paymentInfo);
    }
}
